package easier.window.dialog.impl;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.Nullable;
import easier.window.dialog.BaseDialogFragment;
import easier.window.window.R;

/**
 * 通用布局:只有确定的dialog,从屏幕中央显示,右上角有x可以关闭
 */
public class ConfirmDialogFragment extends BaseDialogFragment {

    protected TextView mTitle;
    protected TextView mContent;
    protected TextView mConfirm;
    protected ImageView mClose;

    @Override
    protected Dialog createDialog( Context context, @Nullable Bundle savedInstanceState ) {

        Dialog dialog = super.createDialog( context, savedInstanceState );

        View root = View.inflate( context, R.layout.close_tips, null );
        setDialogView( root );

        mTitle = (TextView) root.findViewById( R.id.title );
        mContent = (TextView) root.findViewById( R.id.content );
        mConfirm = (TextView) root.findViewById( R.id.confirm );
        mClose = (ImageView) root.findViewById( R.id.close );

        mTitle.setText( "温馨提示" );
        mContent.setText( "温馨提示" );
        mConfirm.setText( "确定" );

        mClose.setOnClickListener( new OnClickListener() {
            @Override
            public void onClick( View v ) {

                dismiss();
            }
        } );

        mConfirm.setOnClickListener( new OnClickListener() {
            @Override
            public void onClick( View v ) {

                dismiss();
            }
        } );

        return dialog;
    }

}
